#include <iostream>
#include <vector>

void ReadInput (std::vector <int> &elements, int array_size) {
    for (int iteration = 0; iteration < array_size; ++iteration) {
        int element;
        std::cin >> element;
        elements.push_back(element);
    }
}

void PrintAnswer (std::vector <int> &answer) {
    for (auto element : answer) {
        std::cout << element << " ";
    }
}

template <typename iterator_type>
void Merge (iterator_type first_begin, iterator_type first_end,
            iterator_type second_begin, iterator_type second_end,
            std::vector <int> &output_vector) {
    while (first_begin != first_end || second_begin != second_end) {
        if (first_begin == first_end) {
            output_vector.push_back (*second_begin);
            ++second_begin;
        } else if (second_begin == second_end) {
            output_vector.push_back (*first_begin);
            ++first_begin;
        } else {
            if (*first_begin < *second_begin) {
                output_vector.push_back (*first_begin);
                ++first_begin;
            } else {
                output_vector.push_back (*second_begin);
                ++second_begin;
            }
        }
    }
}

int main() {
    int first_array_size;
    std::cin >> first_array_size;
    std::vector <int> first_array;
    ReadInput (first_array, first_array_size);
    int second_array_size;
    std::cin >> second_array_size;
    std::vector <int> second_array;
    ReadInput (second_array, second_array_size);
    std::vector <int> answer;

    Merge (first_array.begin(), first_array.end(),
           second_array.begin(), second_array.end(), answer);
    PrintAnswer (answer);
}
